<!--
 * @Author: 李小晴 2689279066@qq.com
 * @Date: 2023-03-16 10:34:03
 * @LastEditors: 李天惊 uf_lee@163.com
 * @LastEditTime: 2025-03-24 14:00:24
 * @FilePath: \global-brain\global-brain-admin\src\views\Error\404.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup lang="ts">
import { Error } from '@/components/Error'
import { ElMessageBox } from 'element-plus'
import { usePermissionStore } from '@/store/modules/permission'
import { useRouter } from 'vue-router'
import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n()
// import { useCache } from '@/hooks/web/useCache'
// const { wsCache } = useCache()
// const token = wsCache.get('token')
const { push } = useRouter()

const permissionStore = usePermissionStore()

const errorClick = () => {
  console.log(permissionStore.addRouters, 'permissionStore.addRouters.length')
  if (permissionStore.addRouters.length > 1) {
    push(permissionStore.addRouters[0]?.path as string)
  } else {
    ElMessageBox.confirm('回到用户中心', t('common.delWarning'), {
      confirmButtonText: t('common.delOk'),
      cancelButtonText: t('common.delCancel'),
      type: 'warning'
    })
      .then(async () => {
        let openUrl = import.meta.env.VITE_SYS_URL
        window.open(openUrl, '_blank')
      })
      .catch(() => {})
  }
}
</script>

<template>
  <Error @error-click="errorClick" />
</template>
